<template>
  <el-menu
    :class="['aside-container', { 'is-collapse': isCollapse }]"
    active-text-color="#ffd04b"
    background-color="#545c64"
    class="aside-container"
    default-active="2"
    text-color="#fff"
    @open="handleOpen"
    @close="handleClose"
    :collapse="isCollapse"
  >
    <p class="logo-lg">{{ isCollapse ? "DIDI" : "DIDI 培诊" }}</p>
    <TreeMune :index="1" :menuData="menuData" />
  </el-menu>
</template>

<script setup>
// imports and composables
import { reactive, defineProps, computed } from "vue";
import { storeToRefs } from "pinia";
import { useRouter } from "vue-router";
import { useMenuStore } from "../store/index";
import TreeMune from "./treeMune.vue";
const handleOpen = () => {};
const handleClose = () => {};
const router = useRouter();

const useMenuData = useMenuStore();

const menuData = computed(() => {
  return useMenuData.routeList;
});

// 方案2：使用 storeToRefs
const { isCollapse } = storeToRefs(useMenuData);
</script>

<style lang="less" scoped>
/* styles */
.aside-container {
  height: 100%;
  width: 230px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: width; /* 提示浏览器优化 */
  .logo-lg {
    font-size: 20px;
    text-align: center;
    height: 50px;
    line-height: 50px;
    color: #fff;
  }
  &.is-collapse {
    width: 60px;
  }
}
</style>